package org.zch.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.zch.dao.OpenAdminDAO;
import org.zch.dao.ZuoRuiDAO;
import org.zch.entity.po.OpenAdminPO;
import org.zch.entity.po.ZuoRuiPO;
import org.zch.service.OpenAdminService;
import org.zch.service.ZuoRuiService;

import java.util.Date;
import java.util.List;

/**
 * 管理员
 * 方法实现层
 *
 * @author 赵昌虎
 */
@Service
public class OpenAdminServiceImpl implements OpenAdminService {

    @Autowired
    private OpenAdminDAO openAdminDAO;


    @Override
    public Integer addOpen(String news, String version, String tips) {
        OpenAdminPO openAdminPO = new OpenAdminPO();
        openAdminPO.setNews(news);
        openAdminPO.setVersion(version);
        openAdminPO.setTips(tips);
        return openAdminDAO.insert(openAdminPO);
    }

    @Override
    public OpenAdminPO getOpen() {
        OpenAdminPO re = null;
        LambdaQueryWrapper<OpenAdminPO> queryWrapper = OpenAdminPO.getQueryWrapper();
        List<OpenAdminPO> zuoRuiPO = openAdminDAO.selectList(queryWrapper);
        if (!zuoRuiPO.isEmpty()){
            re = zuoRuiPO.get(0);
        }
        return re;
    }
}
